<?php
//Set up the system
require('config.include.php');
//Auth stuff
require('auth.include.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Set Template</title>
<link rel="stylesheet" href="admin.css" />
</head>

<body>
<div id="wrapper">
	<div id="header">
    	<?php echo('<a href="../" class="breadcrumb">'.SITE_TITLE.'</a> &raquo; <a href="dashboard.php" class="breadcrumb">Dashboard</a> &raquo; <a href="template.php" class="breadcrumb">Select Template</a>'); ?>
    </div>
    <div id="sidebar">
<?php
	require('nav.include.php');
?>
    </div>
    <div id="content">
        <div class="contentblock">
		<h2>Select Template</h2>
		<?php
		$themeDir=opendir('../'.THEMEFOLDER);
		$noPrevPic='../themes/nopreview.jpg';
		while(($template=readdir($themeDir))!==false) {
			$base='../'.THEMEFOLDER.'/'.$template.'/'.$template;
			$picLoc=$base.'.jpg';
			$descLoc=$base.'.txt';
			$desc=file_exists($descLoc)?file_get_contents($descLoc):'No Description';
			$desc='<span class="themeDesc">'.$desc.'</span>';
			if($template!='.'&&$template!='..'&&is_dir('../'.THEMEFOLDER.'/'.$template))
				echo('<a href="settings.php?THEME='.$template.'&amp;save"><h3 class="clearBoth">'.$template.'</h3>
				<img class="themeThumb" alt="'.$template.' thumbnail" src="'.(file_exists($picLoc)?$picLoc:$noPrevPic).'" /></a>'.$desc.'<br />');
		}
		?>
		</div>
    </div>
    <div id="footer">
    </div>
</div>
</body>
</html>